package com.situ.controller.cst_activity;

import com.situ.entity.cst_linkman.CstLinkman;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.situ.service.cst_activity.CstActivityService;
import com.situ.entity.cst_activity.CstActivity;
import com.situ.util.*;

import java.util.List;

/**
 * CstActivity的路由接口服务
 * 
 * @author胡文
 *
 */
//
@RestController
public class CstActivityController {

	/** CstActivityService服务 */
	@Autowired
	private CstActivityService cstActivityService;
	
	/**
	 * 查询所有CstActivity数据的方法
	 * @param value
	 * @return
	 */
	@RequestMapping(value = "/CstActivity/query", produces = {"application/json;charset=UTF-8"})
	public ResponseData query(CstActivity value) {

		return ResponseData.ok().putDataValue("list",cstActivityService.find(value));
	}
	
	/**
	 * 通过id查询CstActivity数据的方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "/CstActivity/queryById/{id}", produces = {"application/json;charset=UTF-8"})
	public ResponseData queryById(@PathVariable(name="id") int id) {
		 return ResponseData.ok().putDataValue("obj",cstActivityService.findOne(id));
	}
	
	/**
	 * 插入CstActivity属性不为空的数据方法
	 * @RequestMapping(value = "/CstActivity/save")
     * 	public ResponseData save(CstActivity value) {
     *
     * 		return ResponseData.ok().putDataValue("obj", cstActivityService.saveNotNull(value));
     * 	}
	 * @return
	 */

	
	/**
	 * 更新CstActivity属性不为空的数据方法
	 *
	 * @return
     *
     * @RequestMapping(value = "/CstActivity/update", produces = {"application/json;charset=UTF-8"})
     * 	public ResponseData update(CstActivity value) {
     * 		return ResponseData.ok().putDataValue("obj",cstActivityService.updateNotNullById(value));
     * 	}
	 */


	/**
	 * 通过id删除CstActivity数据方法
	 *
	 * @return
     *
     * @RequestMapping(value = "/CstActivity/delById/{id}", produces = {"application/json;charset=UTF-8"})
     * 	public ResponseData delById(@PathVariable(name="id") int id) {
     * 		return ResponseData.ok().putDataValue("obj",cstActivityService.deleteById(id));
     * 	}
	 */



    //带分页的查询全部
//@ApiOperation("带分页的查询全部")
/*
    @RequestMapping(value = "/CstActivity/queryPage", produces = {"application/json;charset=UTF-8"})
    public ResponseData queryPage(CstActivity value,
                             @RequestParam(defaultValue = "1",required = false) int pageNum ,
                             @RequestParam(defaultValue = "5",required = false) int pageSize) {

	    PageHelper.startPage(pageNum, pageSize);
        List<SysMight> list = sysMightService.find2(value);
    PageInfo pageInfo = new PageInfo<SysMight>(list,5);

        return ResponseData.ok()
        // .putDataValue("list", list)
        .putDataValue("pageInfo",pageInfo);
        }
 */


    //根据客户编号查询所有交往记录返回一个集合
    @RequestMapping("/CstActivity/queryatvcustno/{id}")   //springboot 可以直接转json
    public List<CstActivity> queryall(@PathVariable String id) {
        List<CstActivity> list =cstActivityService.queryatvcustno(id);
        return list; //自动转json  springboot
    }

    //添加交往记录
    @RequestMapping("/CstActivity/save")
    public String save(CstActivity value){
        cstActivityService.saveact(value);
        return "添加成功";
    }

    //修改交往记录
    @RequestMapping("/CstActivity/update")
    public String update(CstActivity value) {
        cstActivityService.update(value);
        return "修改成功";
    }

    @RequestMapping("/CstActivity/delById/{id}")
    public String delById(@PathVariable int id) {
        cstActivityService.deleteById(id);
        return "删除成功";
    }

}
